home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / oldwish / old / wishInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-03  |  13.5 KB  |  396 lines

  1. /*
  2.  * fsflatInt.h --
  3.  *
  4.  *    Internal declarations for fsflat display.
  5.  *
  6.  * Copyright 1987 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: fsflatInt.h,v 1.1 88/10/03 12:49:03 mlgray Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _FSFLATINT
  20. #define _FSFLATINT
  21.  
  22. #include <sys/param.h>
  23. #ifndef AllPlanes
  24. #include <X11/Xlib.h>
  25. #endif
  26. #ifndef USPosition
  27. #include <X11/Xutil.h>
  28. #endif
  29. #include "cmd.h"
  30. #include "mx.h"
  31. #include "tcl.h"
  32.  
  33. #ifndef Boolean
  34. #define Boolean    int
  35. #define FALSE    0
  36. #define TRUE    1
  37. #endif /* Boolean */
  38.  
  39.  
  40. /*
  41.  * Largest number of ASCII characters required to represent an integer.
  42.  */
  43. #define CVT_INT_BUF_SIZE 34
  44.  
  45. #define    FSFLAT_ROW_SPACING    1    /* a pleasant amount */
  46. #define    FSFLAT_COLUMN_SPACING    15    /* another pleasant amount */
  47. #define UNINITIALIZED        -1    /* number of elements uninitialized */
  48.  
  49. /*
  50.  * To get a control character.
  51.  */
  52. #define    ctrl(c)    (c - 'a' + 1)
  53.  
  54. /*
  55.  * To determine whether finding file system attributes for a file is necessary.
  56.  */
  57. #define FSFLAT_ATTR_NECESSARY_P\
  58.     ((aWindow->displayInstructions & ~FSFLAT_NAME_FIELD) != 0) || \
  59.     ((aWindow->sortingInstructions & ~FSFLAT_ALPHA_SORT) != 0) ? TRUE : FALSE
  60.  
  61. #define FSFLAT_CHAR_TO_WIDTH(numChars, fontPtr)\
  62.     ((numChars) * XTextWidth(fontPtr, "W", 1))
  63.  
  64. /*
  65.  * Sorting flags are a bitwise and of one of the methods
  66.  * with or without "reverse."
  67.  */
  68. /* methods */ 
  69. #define    FSFLAT_ALPHA_SORT    0x01    /* by alphabetical order */
  70. #define    FSFLAT_ATIME_SORT    0x02    /* by access time */
  71. #define    FSFLAT_MTIME_SORT    0x04    /* by data modify time */
  72. #define    FSFLAT_DTIME_SORT    0x08    /* by descriptor modify time */
  73. #define    FSFLAT_SIZE_SORT    0x10    /* by size */
  74. /* reverse */
  75. #define    FSFLAT_REVERSE_SORT    0x20    /* whether to show in reverse order */
  76.  
  77. /*
  78.  * Display flags show which fields should be present in the display.
  79.  */
  80. #define    FSFLAT_NAME_FIELD    0x001    /* name of the file */
  81. #define    FSFLAT_FULLNAME_FIELD    0x002    /* full pathname to the file */
  82. #define    FSFLAT_ATIME_FIELD    0x004    /* access time */
  83. #define    FSFLAT_MTIME_FIELD    0x008    /* data modify time */
  84. #define    FSFLAT_DTIME_FIELD    0x010    /* descriptor modify time */
  85. #define    FSFLAT_SIZE_FIELD    0x020    /* size of the file in bytes */
  86. #define    FSFLAT_DEVICE_FIELD    0x040    /* major and minor device numbers */
  87. #define    FSFLAT_PERM_FIELD    0x080    /* permissions, owner and group */
  88. #define    FSFLAT_TYPE_FIELD    0x100    /* directory? link? ascii? etc.... */
  89.  
  90. #define    FSFLAT_LEFT_BUTTON    0x01
  91. #define    FSFLAT_MIDDLE_BUTTON    0x02
  92. #define    FSFLAT_RIGHT_BUTTON    0x04
  93. #define    FSFLAT_META_BUTTON    0x08
  94. #define    FSFLAT_SHIFT_BUTTON    0x10
  95.  
  96. #define    FSFLAT_MAX_RULE_LENGTH    (2 * 1024)    /* for now the max length
  97.                          * of a rule stored in a
  98.                          * .fsflat file is twice
  99.                          * the max length of a path.
  100.                          * No good reason, just easy. */
  101. /* typedefs for use below */
  102. typedef    struct FsflatFile    FsflatFile;
  103. typedef    struct FsflatGroup    FsflatGroup;
  104. typedef    struct FsflatColumn    FsflatColumn;
  105. typedef    struct FsflatWindow    FsflatWindow;
  106. typedef    struct FsflatSelection    FsflatSelection;
  107. typedef    struct FsflatGroupBinding    FsflatGroupBinding;
  108.  
  109. /*
  110.  * Stuff we need to know about particular file entries.
  111.  * This will contain more information along the lines of a struct    direct
  112.  * soon.  For now, we only keep the name.
  113.  */
  114. struct FsflatFile {
  115.     char    *name;        /* Name of the file */
  116.     struct stat    *attrPtr;    /* file attributes */
  117.     int        length;        /* length of name in pixels */
  118.     int        x;        /* x and y coords of file name */
  119.     int        y;
  120.     int        myColumn;    /* which column the file is in */
  121.     Boolean    selectedP;    /* is the file selected? */
  122.     Boolean    lineP;        /* is whole line selected? */
  123.     Boolean    highlightP;    /* whether or not it is highlighted */
  124.     FsflatGroup    *myGroupPtr;    /* ptr back to my group */
  125.     struct    FsflatFile    *nextPtr;    /* the next one */
  126. };
  127.  
  128. /*
  129.  * Each group has a selection rule associated with it, and the files selected
  130.  * by that rule.
  131.  */
  132. #define    COMPARISON    0
  133. #define    PROC        1
  134. struct FsflatGroup {
  135.     int        myColumn;        /* which column I'm in */
  136.     Window    headerWindow;        /* window for header */
  137.     int        x;            /* x and y coords of group header */
  138.     int        y;
  139.     int        width;            /* width and height of header */
  140.     int        height;
  141.     int        entry_x;        /* coords of old entry window */
  142.     int        entry_y;
  143.     int        entry_width;
  144.     FsflatFile    *fileList;        /* list of selected files */
  145.     int        defType;        /* type of rule, tcl proc or pattern */
  146.     char    *rule;            /* selection rule */
  147.     FsflatGroupBinding    *groupBindings;    /* mouse button/command bindings */
  148.     int        length;            /* length of rule or name in pixels */
  149.     char    editHeader[FSFLAT_MAX_RULE_LENGTH];    /* for entry window */
  150.     Boolean    selectedP;        /* is the group selected? */
  151.     Boolean    highlightP;        /* whether or not it is highlighted */
  152.     struct    FsflatGroup    *nextPtr;    /* the next one in list */
  153. };
  154.  
  155. /*
  156.  * Per-column information.  This data structure could be extended to point to
  157.  * the first file name and group appearing in the column so that redraw
  158.  * could be done be region, perhaps just columns.  Things seem fast enough
  159.  * for now, though, so I won't bother.
  160.  */
  161. struct FsflatColumn {
  162.     int        x;        /* x coordinate of left side of column */
  163. };
  164.  
  165. /*
  166.  * For each browser instance, there is a structure of this sort stored
  167.  * in the FsflatWindowTable.  The structure contains information about
  168.  * the window that the file system client wants to keep.
  169.  */
  170. struct FsflatWindow {
  171.     Window    surroundingWindow;        /* the surrounding window in
  172.                          * which the subwindows are
  173.                          * packed */
  174.     Window    titleWindow;            /* displays the full pathname
  175.                          * of the current directory and
  176.                          * is editable for people to
  177.                          * type in new desired dir */
  178.     Window    divider1Window;            /* thin window for a border
  179.                          * between title and menu */
  180.     Window    menuBar;            /* menu window under title */
  181.     Window    divider2Window;            /* thin window for a border
  182.                          * between menu and sort */
  183.     Window    sortWindow;            /* displays sorting method */
  184.     Window    divider3Window;            /* thin window for a border
  185.                          * between sort and fields */
  186.     Window    fieldsWindow;            /* window listing fields in
  187.                          * display (time, size, etc) */
  188.     Window    divider4Window;            /* thin window for a border
  189.                          * between fields and display */
  190.     Window    scrollWindow;            /* scrollbar window */
  191.     Window    divider5Window;            /* thin window for a border
  192.                          * between scrollbar and
  193.                          * display */
  194.     Window    txOutsideWindow;        /* tx window */
  195.     Window    divider6Window;            /* thin window for a border
  196.                          * between tx and display */
  197.     Window    displayWindow;            /* the display window */
  198.     int        windowHeight;            /* height of display window */
  199.     int        windowWidth;            /* width of display window */
  200.     Boolean    resizeP;            /* can we change geometry? */
  201.     Boolean    pickSizeP;            /* size window initially */
  202.     int        foreground;            /* foreground color */
  203.     int        background;            /* background color */
  204.     int        border;                /* border color */
  205.     int        selection;            /* selection color */
  206.     int        borderWidth;            /* width of surrounding border,
  207.                          * not really used, maybe... */
  208.     XFontStruct    *fontPtr;            /* font used for display */
  209.     GC        textGc;
  210.     GC        reverseGc;
  211.     int        titleForeground;
  212.     int        titleBackground;
  213.     int        titleBorder;
  214.     XFontStruct    *titleFontPtr;            /* font used for title */
  215.     int        txForeground;
  216.     int        txBackground;
  217.     int        txBorder;
  218.     int        menuForeground;
  219.     int        menuBackground;
  220.     int        menuBorder;
  221.     int        sortForeground;
  222.     int        sortBackground;
  223.     int        fieldsForeground;
  224.     int        fieldsBackground;
  225.     int        entryForeground;
  226.     int        entryBackground;
  227.     int        scrollForeground;
  228.     int        scrollBackground;
  229.     int        scrollElevator;
  230.     char    *geometry;            /* window geometry */
  231.     char    dir[MAXPATHLEN+1];    /* The current dir of the
  232.                          * display.  This is the full
  233.                          * pathname of the top node
  234.                          * in the display. */
  235.     char    editDir[MAXPATHLEN+1];    /* Contains dir
  236.                          * name too, but is meant for
  237.                          * editing in the title window.
  238.                          * By having both dir and
  239.                          * editDir, we don't lose the
  240.                          * actual dir when users type
  241.                          * in a potential new dir. */
  242.     int        displayInstructions;        /* display field flags */
  243.     int        sortingInstructions;        /* sorting flags */
  244.     int        maxNameLength;            /* strln of longest name */
  245.     int        maxEntryWidth;            /* longest entry width in chars,
  246.                          * not window units */
  247.     int        numElements;            /* total number of files */
  248.     int        numGroups;            /* number of groups */
  249.     int        numHiddenGroups;        /* number of groups hidden
  250.                          * because they are empty. */
  251.     Boolean    hideEmptyGroupsP;        /* whether or not to display
  252.                          * headers for empty groups. */
  253.     int        totalDisplayEntries;        /* total # of files + headers
  254.                          * plus spaces to display. */
  255.     int        numRows;            /* number of rows in display */
  256.     int        rowHeight;            /* height in pixels of rows */
  257.     int        firstElement;            /* first visible element */
  258.     int        lastElement;            /* last visible element */
  259.     int        columnWidth;            /* width of columns in pixels */
  260.     FsflatColumn    *columns;        /* dynamic array of columns */
  261.     int        usedCol;            /* index of last column in
  262.                          * display currently used */
  263.     int        maxColumns;            /* max # of columns allocated */
  264.     FsflatGroup    *groupList;            /* list of groups */
  265.     FsflatSelection    *selectionList;        /* list of selected stuff */
  266.     Cmd_Table    cmdTable;            /* window command interface */
  267.     Tcl_Interp    *interp;            /* tcl interpreter */
  268. #ifdef NOTDEF
  269.     char    *cmdString;            /* command in a cmd window */
  270. #endif NOTDEF
  271.     Boolean    dontDisplayChangesP;        /* to keep commands from
  272.                          * attempting redisplay while
  273.                          * we're building the
  274.                          * display from sourced
  275.                          * startup files. */
  276. };
  277.  
  278. /*
  279.  * For keeping lists of selected stuff.
  280.  */
  281. struct FsflatSelection {
  282.     Boolean        fileP;        /* if false, it's a group */
  283.     Boolean        lineP;        /* if true, then the whole line */
  284.     union {
  285.     FsflatFile    *filePtr;
  286.     FsflatGroup    *groupPtr;
  287.     } selected;
  288.     struct FsflatSelection    *nextPtr;
  289. };
  290.  
  291. struct FsflatGroupBinding {
  292.     int        button;
  293.     char    *command;
  294.     struct FsflatGroupBinding    *nextPtr;
  295. };
  296.  
  297. /* Structure used to build command tables. */
  298. typedef    struct    {
  299.     char    *name;            /* command name */
  300.     int        (*proc)();        /* procedure to process command */
  301. } CmdInfo;
  302.  
  303.  
  304. /* externs */
  305.  
  306. extern    XContext    fsflatWindowContext;    /* table of window data */
  307. extern    XContext    fsflatGroupWindowContext;/* table of group data */
  308. extern    int        fsflatWindowCount;    /* reference count of windows */
  309.                             /* error reporting */
  310. extern    char        fsflatErrorMsg[/* (2*MAXPATHLEN + 50) */];
  311. extern    Boolean        fsflatDebugP;        /* whether debugging is on */
  312. extern    Boolean        fsflatResizeP;        /* can application resize? */
  313. extern    Boolean        fsflatPickSizeP;    /* can appl. pick size? */
  314. extern    Display        *fsflatDisplay;        /* the display */
  315. extern    Boolean        fsflatShowEmptyGroupsP;    /* show headers with no files */
  316. extern    int        fsflatRootHeight;    /* info about root window */
  317. extern    int        fsflatRootWidth;
  318. extern    char        *fsflatApplication;    /* application name */
  319. extern    char        fsflatCurrentDirectory[];    /* keep track of
  320.                              * current directory */
  321.  
  322. /*    Commands in manual page. */
  323. extern    int    FsflatQuitCmd();
  324. extern    int    FsflatToggleSelectionCmd();
  325. extern    int    FsflatToggleSelEntryCmd();
  326. extern    int    FsflatCloseCmd();
  327. extern    int    FsflatRedrawCmd();
  328. extern    int    FsflatSelectionCmd();
  329. extern    int    FsflatChangeDirCmd();
  330. extern    int    FsflatMenuCmd();
  331. extern    int    FsflatSortFilesCmd();
  332. extern    int    FsflatChangeFieldsCmd();
  333. extern    int    FsflatChangeGroupCmd();
  334. extern    int    FsflatDefineGroupCmd();
  335. extern    int    FsflatOpenCmd();
  336. extern    int    FsflatExecCmd();
  337. extern    int    FsflatBindCmd();
  338. extern    int    FsflatGroupBindCmd();
  339. extern    int    FsflatResizeCmd();
  340. extern    int    FsflatPatternCompareCmd();
  341.  
  342. /* Other externs. */
  343. extern    void    FsflatEditDir();
  344. extern    void    FsflatEditRule();
  345. extern    void    FsflatSelectDir();
  346. extern    void    FsflatScroll();
  347. extern    FsflatWindow    *FsflatCreate();
  348. extern    void    FsflatInit();
  349. extern    int    FsflatGatherNames();
  350. extern    int    FsflatGatherSingleGroup();
  351. extern    void    FsflatSetPositions();
  352. extern    void    FsflatRedraw();
  353. extern    void    FsflatRedrawFile();
  354. extern    void    FsflatGetFileFields();
  355. extern    void    FsflatRedrawGroup();
  356. extern    void    FsflatSetWindowAndRowInfo();
  357. extern    void    FsflatHandleDrawingEvent();
  358. extern    void    FsflatHandleDestructionEvent();
  359. extern    void    FsflatHandleMonitorUpdates();
  360. extern    void    FsflatMouseEvent();
  361. extern    void    FsflatHighlightMovement();
  362. extern    void    FsflatHandleEnterEvent();
  363. extern    char    *FsflatCanonicalDir();
  364. extern    void    FsflatGarbageCollect();
  365. extern    void    FsflatChangeSelection();
  366. extern    void    FsflatClearWholeSelection();
  367. extern    FsflatGroup    *FsflatMapCoordsToGroup();
  368. extern    FsflatFile    *FsflatMapCoordsToFile();
  369. extern    void    FsflatCmdTableInit();
  370. extern    void    FsflatAddGroupBinding();
  371. extern    void    FsflatDeleteGroupBindings();
  372. extern    char    *FsflatGetGroupBinding();
  373. extern    int    FsflatDoCmd();
  374. extern    void    FsflatChangeDir();
  375. extern    void    FsflatSourceConfig();
  376. extern    void    Cmd_BindingCreate();
  377. extern    char    *Cmd_BindingGet();
  378. extern    void    Cmd_BindingDelete();
  379. extern    Boolean    Cmd_EnumBindings();
  380. extern    int    Cmd_MapKey();
  381. extern    Cmd_Table    Cmd_TableCreate();
  382. extern    void    Cmd_TableDelete();
  383. extern    void    FsflatCvtToPrintable();
  384. extern    void    FsflatKeyProc();
  385. extern    void    FsflatMenuProc();
  386. extern    void    FsflatMenuEntryProc();
  387. extern    void    FsflatSetSort();
  388. extern    void    FsflatGetCompareProc();
  389. extern    void    FsflatGarbageGroup();
  390. extern    int    FsflatDoTclSelect();
  391.  
  392. /* should be in string.h! */
  393. extern    char    *index();
  394.  
  395. #endif _FSFLATINT
  396.